def lightmat(n, ms, qs):  # n*n
    """
        n ([type]): [description]
        ms ([x, y]): [description]
        qs ([x, y]): [description]
    """
    res = 0
    mat = [[0]*n]*n
    for m_xy in ms:
        mat[m_xy[0]][m_xy[1]] = 1
    for q_xy in qs:
        x = q_xy[0]
        y = q_xy[1]
        for i in range(x-1, x+2):
            for j in range(y-1, y+2):
                if not checkArea(n, i, j): continue
                if mat[i][j] == 1:
                    mat[i][j] = 0
                    res += 1
    return res


def checkArea(n, x, y):
    return x >= 0 and x < n and y >= 0 and y < n


# if __name__ == "__main__":
#     n, m, q = 5, 2, 2
#     ms = [[0,0],[4,4]]
#     qs = [[1,1],[1,0]]
#     print(lightmat(5, ms, qs))
#     n, m, q = 5, 2, 2
#     ms = [[0,0],[4,4]]
#     qs = [[1,1],[1,1]]
#     print(lightmat(5, ms, qs))

import sys
if __name__ == "__main__":
    # 读取第一行的n
    n = int(sys.stdin.readline().strip())
    for i in range(n):  # 组数
        
        # 读取第一行
        line = sys.stdin.readline().strip()
        n, m, q = line[0], line[1], line[2]
        ms, qs = [], []
        for i in range(m):
            line = sys.stdin.readline().strip()
            ms.append(list(map(int, line.split())))
        for i in range(q):
            line = sys.stdin.readline().strip()
            qs.append(list(map(int, line.split())))
        # 函数计算
        print(lightmat(n, ms, qs))
